home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / Ivy 1.0fc1 / Demo Scripts / CheckDialogMargins.vu
Encoding:
Text File  |  1993-08-13  |  1.2 KB  |  50 lines  |  [TEXT/MPS ]

  1. # This script assumes that the target Macintosh has a Dialog up on the screen.
  2. # The script will check the margins of the dialog to make sure they are wide
  3. # enough.
  4.  
  5. Libraries "Ivy.vulib";
  6.  
  7. # Set up Ivy.
  8.  
  9. result := IVInit( true );
  10. IVDeleteImageFile( 'theFrame' );
  11. IVDeleteImageFile( 'theDialog' );
  12. IVDeleteImageFile( 'theDiff' );
  13.  
  14. # Get the dimensions of the front Dialog.
  15.  
  16. match[ window o:1 r:?theRect s:Dialog ];
  17. if ( isUndefined( theRect ) )
  18.     begin
  19.         println 'There is no front dialog!';
  20.         exit;
  21.     end;
  22.     
  23. theInsetRect := {     8, 8,
  24.                     theRect[3] - theRect[1] - 8,  theRect[4] - theRect[2]- 8 };
  25.  
  26. # Capture Dialog image, but erase its contents.
  27.  
  28. result := IVCreateImageFile( 'theFrame', theRect, { theInsetRect } );
  29. if ( result[2] <>true )
  30.     exit;
  31.     
  32. # Capture the entire Dialog image.
  33.  
  34. result := IVCreateImageFile( 'theDialog', theRect );
  35. if ( result[2] <> true )
  36.     exit;
  37.  
  38. theInsetRect := {     14, 14,
  39.                                             theRect[3] - theRect[1] - 14,  theRect[4] - theRect[2]- 14 };
  40.  
  41. # Compare the two images, but ignore the interior contents.
  42.  
  43. result := IVCompareImageFiles( 'theDialog', 'theFrame', 'theDiff', { theInsetRect } );
  44. if ( result[1] <> 0 )
  45.     exit;
  46.  
  47. if ( result[2] = true )
  48.     println 'The window’s margins were clean.';
  49. else
  50.     println 'The window’s margins were dirty.';